package com.lzx.applib.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.ViewGroup;

import java.util.List;

/**
 * Created by Lzx on 16/11/02 0002.
 */

public abstract class SimplePagerAdapter<T, E extends SimpleViewHolder<T>> extends BPagerAdapter {

    public Context context;
    public List<T> data;

    public SimplePagerAdapter(Context context, List<T> data) {
        this.context = context;
        this.data = data;
    }

    @Override
    public abstract E onCreateViewHolder(ViewGroup parent, int viewType);

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
        ((E)holder).init(getItem(position), position);
    }

    @Override
    public int getItemCount() {
        return data.size();
    }

    @Override
    public T getItem(int position) {
        return data.get(position);
    }
}
